package com.car.web.Car;

import com.car.server.impl.AdminCarSeverImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 删除
 * 通过id
 */
@WebServlet("/car/deleteCar")
public class deleteCar extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String cid = req.getParameter("cid");
        int i = new AdminCarSeverImpl().deleteCar(cid);
        if (i != 0) {
            //成功 跳转
            req.getSession().setAttribute("delete", "删除成功");
        } else {
            req.getSession().setAttribute("delete", "删除失败");
        }
        resp.sendRedirect("InquireMyCar");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

}
